package top.forforever.srb.core.controller.admin;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.forforever.srb.common.result.R;
import top.forforever.srb.core.pojo.entity.Lend;
import top.forforever.srb.core.service.LendService;

import java.util.Map;

/**
 * <p>
 * 标的准备表 前端控制器
 * </p>
 *
 * @author Mr.Jiang
 * @since 2023-04-29
 */
@RestController
@RequestMapping("/admin/core/lend")
public class AdminLendController {

    @Autowired
    private LendService lendService;

    @GetMapping("getList/{pageNum}/{pageSize}")
    public R getList(@PathVariable Integer pageNum,@PathVariable Integer pageSize) {
        Page<Lend> page = lendService.getPageList(pageNum,pageSize);
        return R.ok().data("list",page.getRecords()).data("title",page.getTotal());
    }

    @GetMapping("show/{id}")
    public R show(@PathVariable Long id) {
        Map<String,Object> result = lendService.getLendDetail(id);
        return R.ok().data("lendDetail",result);
    }

    @PutMapping("updateStatusById/{id}")
    public R makeLoan(@PathVariable Long id) {
        lendService.makeLoan(id);
        return R.ok();
    }

}

